home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / dviselect / fio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-16  |  900 b   |  42 lines

  1. /*
  2.  * Copyright (c) 1987 University of Maryland Department of Computer Science.
  3.  * All rights reserved.  Permission to copy for any purpose is hereby granted
  4.  * so long as this copyright notice remains intact.
  5.  */
  6.  
  7. #ifndef lint
  8. static char rcsid[] = "$Header: fio.c,v 1.1 88/02/11 17:08:48 jim Exp $";
  9. #endif
  10.  
  11. /*
  12.  * File I/O subroutines for getting bytes, words, 3bytes, and longwords.
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include "types.h"
  17. #include "fio.h"
  18.  
  19. static char eofmsg[] = "unexpected EOF";
  20.  
  21. /* for symmetry: */
  22. #define    fGetByte(fp, r)    ((r) = getc(fp))
  23. #define    Sign32(i)    (i)
  24.  
  25. #define make(name, func, signextend) \
  26. i32 \
  27. name(fp) \
  28.     register FILE *fp; \
  29. { \
  30.     register i32 n; \
  31.  \
  32.     func(fp, n); \
  33.     if (feof(fp)) \
  34.         error(1, 0, eofmsg); \
  35.     return (signextend(n)); \
  36. }
  37.  
  38. make(GetByte,  fGetByte,  Sign8)
  39. make(GetWord,  fGetWord,  Sign16)
  40. make(Get3Byte, fGet3Byte, Sign24)
  41. make(GetLong,  fGetLong,  Sign32)
  42.